package com.dhcc.DRGsHosp.facade.impl.assembler;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import com.dhcc.DRGsHosp.core.domain.ScheduleJob;
import com.dhcc.DRGsHosp.facade.dto.ScheduleJobDTO;

public class ScheduleJobAssembler {
	public static ScheduleJobDTO  toDTO(ScheduleJob  scheduleJob){
		if (scheduleJob == null) {
			return null;
		}
		ScheduleJobDTO result  = new ScheduleJobDTO();
		result.setBeanClass(scheduleJob.getBeanClass());
		result.setCreateTime(scheduleJob.getCreateTime());
		result.setCronExpression(scheduleJob.getCronExpression());
		result.setDescription(scheduleJob.getDescription());
		result.setJobData(scheduleJob.getJobData());
		result.setJobGroup(scheduleJob.getJobGroup());
		result.setJobId(scheduleJob.getJobId());
		result.setJobName(scheduleJob.getJobName());
		result.setJobStatus(scheduleJob.getJobStatus());
		result.setMethodName(scheduleJob.getMethodName());
		result.setUpdateTime(scheduleJob.getUpdateTime());
		result.setJobExecuteTime(scheduleJob.getJobExecuteTime());
 	    return result;
	 }
	
	public static List<ScheduleJobDTO>  toDTOs(Collection<ScheduleJob>  scheduleJobs){
		if (scheduleJobs == null) {
			return null;
		}
		List<ScheduleJobDTO> results = new ArrayList<ScheduleJobDTO>();
		for (ScheduleJob each : scheduleJobs) {
			results.add(toDTO(each));
		}
		return results;
	}
	
	 public static ScheduleJob  toEntity(ScheduleJobDTO  scheduleJobDTO){
	 	if (scheduleJobDTO == null) {
			return null;
		}
	 	ScheduleJob result  = new ScheduleJob();
		result.setBeanClass(scheduleJobDTO.getBeanClass());
		result.setCreateTime(scheduleJobDTO.getCreateTime());
		result.setCronExpression(scheduleJobDTO.getCronExpression());
		result.setDescription(scheduleJobDTO.getDescription());
		result.setJobData(scheduleJobDTO.getJobData());
		result.setJobGroup(scheduleJobDTO.getJobGroup());
		result.setJobId(scheduleJobDTO.getJobId());
		result.setJobName(scheduleJobDTO.getJobName());
		result.setJobStatus(scheduleJobDTO.getJobStatus());
		result.setMethodName(scheduleJobDTO.getMethodName());
		result.setUpdateTime(scheduleJobDTO.getUpdateTime());
		result.setJobExecuteTime(scheduleJobDTO.getJobExecuteTime());
 	  	return result;
	 }
	
	public static List<ScheduleJob> toEntities(Collection<ScheduleJobDTO> scheduleJobDTOs) {
		if (scheduleJobDTOs == null) {
			return null;
		}
		
		List<ScheduleJob> results = new ArrayList<ScheduleJob>();
		for (ScheduleJobDTO each : scheduleJobDTOs) {
			results.add(toEntity(each));
		}
		return results;
	}
}
